﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YJTMedicalAideManage.Cores.Events
{
    public class StatusEvent
    {
        private static StatusEvent _instance;

        // 私有构造函数，防止外部直接实例化
        private StatusEvent() { }

        public static StatusEvent Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new StatusEvent();
                }
                return _instance;
            }
        }
        public delegate void StatusEventHandler(string v);

        public event StatusEventHandler OnMessageReceived;

        public void PushMessage(string v)
        {
            OnMessageReceived?.Invoke(v);
        }
        public void Subscribe(StatusEventHandler handler)
        {
            OnMessageReceived += handler;
        }

        public void Unsubscribe(StatusEventHandler handler)
        {
            OnMessageReceived -= handler;
        }
    }
}
